const express = require('express')
const app = express()
app.listen(3000)

const path = require('path')
const time = require('time-stamp')
const session = require('cookie-session')

app.use('/static',express.static(path.join(__dirname,'view/static')))

app.use(express.urlencoded({extends:false}))
app.use(express.json());

app.use(session({
    keys:['我是秘钥啊啊啊']
}))

app.use((req,res,next)=>{
    req.time = time('YYYY年MM月DD日  HH:mm:ss')
    next()
})

const userRouter = require('./userRouter')
app.use(userRouter)

app.use((err,req,res,next)=>{
    res.send({code:400,msg:err})
})
